package com.example.springcloudribbon.services.impl;

import com.example.springcloudribbon.services.TestServiceInterface;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class TestServiceInterfaceImpl implements TestServiceInterface {
    @Autowired
    RestTemplate restTemplate;

    @Autowired
    LoadBalancerClient loadBalancerClient;

    @Override
    public String port() {
        this.loadBalancerClient.choose("user-center");
        String info = restTemplate.getForObject("http://user-center/test", String.class);
        return info;
    }

}
